﻿@model HWmanagementClient.Models.StudentHomeworks
@{
    ViewBag.Title = "Grades";
}
<script type="text/javascript">
    $(function () {
        $("#studentcourses").accordion();
    });

    var markup = '<tr id="trashable">' +
                        '<td><strong>${title}</strong> (ID: ${id}, C: ${courseid}, U: ${userid})' +
                        '<br>Utoljára beadott fájl: <a href="${fileurl}">${filename}</a><br>' +
                        '<em>Beadási határidő: <strong>${deadline2}</strong></em></td>' +
                        '<td> <em>Érdemjegy: </em>' +
                        '{{if grade == 0}}' +
                        'NINCS' +
                        '{{else}}' +
                        '${grade}' +
                        '{{/if}}' +
                        '<br> <em>Megjegyzés:</em></br>${comment}' +
                        '</td>' +
                    '</tr>';

    function getHomework(id) {
        $.ajax({
            type: "POST",
            contentType: "application/json",
            url: "/Student/GetGrade/" + id,
            dataType: "json",
            async: false
        })
			.done(function (msg) {
			    var hw = msg.Grades;
			    //alert(hw);
			    $("tr#trashable").remove();
			    $.template("hw_templ", markup);
			    $("#hwcontainer").before($.tmpl("hw_templ", hw));
			    //$.tmpl("hw_templ", hw).appendTo("#hwcontainer");
			});
    }
</script>
<h2>
    Értékelések</h2>
@if (ViewBag.Succeeded == true)
{
    <div class="ui-widget">
        <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
            <p>
                <span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>
                <strong>OK!</strong> A beadás sikeres volt.</p>
        </div>
    </div>
    <br />
    <br />
}
else if (ViewBag.Succeeded == false)
{
    <div class="ui-widget">
        <div class="ui-state-error ui-corner-all" style="padding: 0 .7em;">
            <p>
                <span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>
                <strong>HIBA!</strong> A házi feladat beadás nem sikerült.</p>
        </div>
    </div>
    <br />
    <br />
}
<table>
    <tr>
        <td valign="top">
            <div id="studentcourses">
                @foreach (var item in Model.Subjects)
                {
                    <h3>
                        @item.name (@item.neptun.ToUpper())</h3>
                    <div>
                        @foreach (var course in item.courses)
                        {
                            <a href="#" onclick="getHomework(@course.id);">[ @course.semester ]</a> 
                        }
                    </div>
                }
            </div>
        </td>
        <td>
            <table>
                <tbody>
                    <tr id="hwcontainer">
                    </tr>
                </tbody>
            </table>
        </td>
    </tr>
</table>
